import java.util.Scanner;
class TreeNode{
    char val;
    TreeNode left;
    TreeNode right;
    public TreeNode(){

    }
    public TreeNode(char val){
        this.val = val;
    }
}

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            i = 0;
            String st = in.nextLine();
            TreeNode root = createTree(st);
            display(root);
        }
    }
    public static int i = 0;
    public static TreeNode createTree(String st){
        TreeNode root = null;
        if(st.charAt(i) != '#'){
            root = new TreeNode(st.charAt(i));
            i++;
            root.left = createTree(st);
            root.right = createTree(st);
        }else{
            i++;
        }
        return root;
    }
    public static void display(TreeNode root){
        if(root == null) return;
        display(root.left);
        System.out.print(root.val + " ");
        display(root.right);
    }
}
